<?php


namespace app\common\validate;


use think\Validate;

class CommonValidate
{
    public static $pageRule = [
        'page_no' => 'require',
        'page_size' => 'require',
    ];

    public static $pageMsg = [
        'page_no.require' => "请输入页码",
        'page_size.require' => "请输入条数",
    ];

    /**
     * 公共验证类
     * @param $rule
     * @param $mes
     * @param $data
     * @return bool|string
     */
    public static function check($rule, $mes, $data)
    {
        $validate = (new Validate())->rule($rule);
        $validate->message($mes);
        if ($validate->check($data)) {
            return true;
        } else {
            return $validate->getError();
        }
    }
}